#pragma once
#include "XTask.h"
#include <cstring>
#include <string>
#include <functional>
class XCOM_API XServeTask:public XTask{
public:
    using ListenCBFunc = std::function<void(evutil_socket_t sock, struct sockaddr *sa, int socklen, void *arg)>;
    ListenCBFunc m_listenCB = nullptr;
public:
    bool Init() override;
    inline void setIP(const std::string &id)
    {strcpy(m_ip,id.c_str());}
    inline std::string ip()
    {return m_ip;}
    inline void setPort(unsigned short port)
    {m_servePort=port;}
    inline unsigned short port()
    {return m_servePort;}
private:
    char m_ip[sizeof("255.255.255.255")]="0.0.0.0";
    unsigned short m_servePort;
    // int m_threadId;
};